package leetcode.easy.getdecimalvalue;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import util.adt.ListNode;

public class SolutionTest {

    private static Solution solution;

    @BeforeClass
    public static void setup() {
        solution = new Solution();
    }

    @AfterClass
    public static void tearUp() {
        solution = null;
    }

    @Test
    public void test1() {
        ListNode head = ListNode.fromArray(new int[] {1, 0, 1});
        Assert.assertEquals(5, solution.getDecimalValue(head));
    }

    @Test
    public void test2() {
        ListNode head = ListNode.fromArray(new int[] {0});
        Assert.assertEquals(0, solution.getDecimalValue(head));
    }

    @Test
    public void test3() {
        ListNode head = ListNode.fromArray(new int[] {1});
        Assert.assertEquals(1, solution.getDecimalValue(head));
    }

    @Test
    public void test4() {
        ListNode head = ListNode.fromArray(new int[] {1,0,0,1,0,0,1,1,1,0,0,0,0,0,0});
        Assert.assertEquals(18880, solution.getDecimalValue(head));
    }

    @Test
    public void test5() {
        ListNode head = ListNode.fromArray(new int[] {0,0});
        Assert.assertEquals(0, solution.getDecimalValue(head));
    }
}
